using System;using System.Data;using System.Data.SqlClient;using System.Collections.Generic;namespace MyWeb.Data{	public class VisitorDAL : SqlDataProvider	{		#region[Visitor_GetById]		public List<Visitor> Visitor_GetById(string Id)		{			List<Data.Visitor> list = new List<Data.Visitor>();			using (SqlCommand dbCmd = new SqlCommand("sp_Visitor_GetById", GetConnection()))			{				Data.Visitor obj = new Data.Visitor();				dbCmd.CommandType = CommandType.StoredProcedure;				dbCmd.Parameters.Add(new SqlParameter("@Id", Id));				SqlDataReader dr = dbCmd.ExecuteReader();				if (dr.HasRows)				{					while (dr.Read())					{						list.Add(obj.VisitorIDataReader(dr));					}
                }
                dr.Close();
                //conn.Close();			}			return list;		}		#endregion		#region[Visitor_GetByTop]		public List<Visitor> Visitor_GetByTop(string Top, string Where, string Order)		{			List<Data.Visitor> list = new List<Data.Visitor>();			using (SqlCommand dbCmd = new SqlCommand("sp_Visitor_GetByTop", GetConnection()))			{				Data.Visitor obj = new Data.Visitor();				dbCmd.CommandType = CommandType.StoredProcedure;				dbCmd.Parameters.Add(new SqlParameter("@Top", Top));				dbCmd.Parameters.Add(new SqlParameter("@Where", Where));				dbCmd.Parameters.Add(new SqlParameter("@Order", Order));				SqlDataReader dr = dbCmd.ExecuteReader();				if (dr.HasRows)				{					while (dr.Read())					{						list.Add(obj.VisitorIDataReader(dr));					}
                }
                dr.Close();
                //conn.Close();			}			return list;		}		#endregion		#region[Visitor_GetByAll]		public List<Visitor> Visitor_GetByAll()		{			List<Data.Visitor> list = new List<Data.Visitor>();			using (SqlCommand dbCmd = new SqlCommand("sp_Visitor_GetByAll", GetConnection()))			{				Data.Visitor obj = new Data.Visitor();				dbCmd.CommandType = CommandType.StoredProcedure;				SqlDataReader dr = dbCmd.ExecuteReader();				if (dr.HasRows)				{					while (dr.Read())					{						list.Add(obj.VisitorIDataReader(dr));					}
                }
                dr.Close();
                //conn.Close();			}			return list;		}		#endregion		#region[Visitor_Paging]		public List<Visitor> Visitor_Paging(string CurentPage, string PageSize)		{			List<Data.Visitor> list = new List<Data.Visitor>();			using (SqlCommand dbCmd = new SqlCommand("sp_Visitor_Paging", GetConnection()))			{				Data.Visitor obj = new Data.Visitor();				dbCmd.CommandType = CommandType.StoredProcedure;				dbCmd.Parameters.Add(new SqlParameter("@CurentPage", CurentPage));				dbCmd.Parameters.Add(new SqlParameter("@PageSize", PageSize));				SqlDataReader dr = dbCmd.ExecuteReader();				if (dr.HasRows)				{					while (dr.Read())					{						list.Add(obj.VisitorIDataReader(dr));					}
                }
                dr.Close();
                //conn.Close();			}		    return list;		}		#endregion		#region[Visitor_Insert]		public bool Visitor_Insert(Visitor data)		{			using (SqlCommand dbCmd = new SqlCommand("sp_Visitor_Insert", GetConnection()))			{				dbCmd.CommandType = CommandType.StoredProcedure;				dbCmd.Parameters.Add(new SqlParameter("@IUserOnline", data.IUserOnline));				dbCmd.Parameters.Add(new SqlParameter("@Ivisitor", data.Ivisitor));				dbCmd.Parameters.Add(new SqlParameter("@IUserOnlineDate", data.IUserOnlineDate));				dbCmd.Parameters.Add(new SqlParameter("@DateOnline", data.DateOnline));				dbCmd.ExecuteNonQuery();			}			//Clear cache			System.Web.HttpContext.Current.Cache.Remove("Visitor");			return true;		}		#endregion		#region[Visitor_Update]		public bool Visitor_Update(Visitor data)		{			using (SqlCommand dbCmd = new SqlCommand("sp_Visitor_Update", GetConnection()))			{				dbCmd.CommandType = CommandType.StoredProcedure;				dbCmd.Parameters.Add(new SqlParameter("@Id", data.Id));				dbCmd.Parameters.Add(new SqlParameter("@IUserOnline", data.IUserOnline));				dbCmd.Parameters.Add(new SqlParameter("@Ivisitor", data.Ivisitor));				dbCmd.Parameters.Add(new SqlParameter("@IUserOnlineDate", data.IUserOnlineDate));				dbCmd.Parameters.Add(new SqlParameter("@DateOnline", data.DateOnline));				dbCmd.ExecuteNonQuery();			}			//Clear cache			System.Web.HttpContext.Current.Cache.Remove("Visitor");			return true;		}		#endregion		#region[Visitor_Delete]		public bool Visitor_Delete(string Id)		{			using (SqlCommand dbCmd = new SqlCommand("sp_Visitor_Delete", GetConnection()))			{				dbCmd.CommandType = CommandType.StoredProcedure;				dbCmd.Parameters.Add(new SqlParameter("@Id", Id));				dbCmd.ExecuteNonQuery();			}			//Clear cache			System.Web.HttpContext.Current.Cache.Remove("Visitor");			return true;		}		#endregion			}}